/*
 * @Author: szx
 * @Date: 2021-12-09 13:45:18
 * @LastEditTime: 2021-12-09 13:49:55
 * @Description:
 * @FilePath: \leetcode\500-599\541\541.js
 */
/**
 * @param {string} s
 * @param {number} k
 * @return {string}
 */
var reverseStr = function (s, k) {
    let res = s.split('');
    for (let i = 0; i < s.length; i += 2 * k) {
        let l = i;
        let r = Math.min(s.length, i + k - 1);
        while (l < r) {
            [res[l], res[r]] = [res[r], res[l]];
            l++;
            r--;
        }
    }
    return res.join('');
};
